Skip to content

Harden binary parameter interpolation against SQL injection#1497

Open
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/sec-20590-binary-sql-injection
Open

Harden binary parameter interpolation against SQL injection#1497
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/sec-20590-binary-sql-injection

Conversation

@sreekanth-db

@sreekanth-db sreekanth-db commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Hardens client-side parameter interpolation so a value typed as BINARY is spliced into the SQL unquoted only when it is a valid X'...' hex literal (the form produced by setBytes). Any other value is escaped as a string literal.

Changes

  • SQLInterpolator: hex-literal allow-list for the BINARY branch; everything else is escaped.
  • Added regression tests covering non-hex and hex-lookalike inputs; existing legitimate setBytes (X'...') behavior is unchanged.

Testing

  • SQLInterpolatorTest, DatabricksPreparedStatementTest, DatabricksTypeUtilTest — all pass (168 tests).
  • Manually verified the change against a live SQL warehouse.

Full detail tracked privately in the associated security ticket.

This pull request and its description were written by Isaac.

When client-side parameter interpolation is enabled, a value typed as
BINARY is now spliced into the SQL unquoted only when it is a valid
X'...' hex literal (as produced by setBytes); any other value is escaped
as a string literal. Adds regression tests for the interpolator.

Co-authored-by: Isaac
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant